import { Navigate } from "react-router-dom";
import { lazy } from "react";
import type { RouteObject } from "react-router-dom";

const Dashboard = lazy(() => import("@/views/dishboard"));
const Home = lazy(() => import("@/views/home"));
const Login = lazy(() => import("@/views/login/index"));
const User = lazy(() => import("@/views/user/index"));
const NotFound = lazy(() => import("@/views/notFound/index"));

// 定义路由数组
const routes: RouteObject[] = [
  {
    path: "/",
    element: <Navigate to="/dashboard" />
  },
  {
    path: "/dashboard",
    element: <Dashboard />,
    children: [
      { path: "/dashboard", element: <Navigate to="/dashboard/index" /> },
      { path: "/dashboard/index", element: <Home /> }
    ]
  },
  { path: "/login", element: <Login /> },
  {
    path: "/user",
    element: <User />,
    children: [
      { path: "/user", element: <Navigate to="/user/list" /> },
      { path: "/user/list", element: <User /> }
    ]
  },
  { path: "*", element: <NotFound /> } // 将 NotFound 路由放在这里
];

// 创建路由
// const router = createBrowserRouter(routes); // 直接传入 routes 数组

export default routes;
